<%@ page import="com.graduation.lastproject.entity.User" %>
<%--
  Created by IntelliJ IDEA.
  User: cyy
  Date: 2020/3/27
  Time: 15:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%
    /*Integer userIntegral=((User)request.getSession().getAttribute("userInfo")).getIntegral();
    Integer userVip=((User)request.getSession().getAttribute("userInfo")).getVip();*/
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<c:set var="ctx" value="<%=basePath%>"  />
<%--<c:set var="userIntegral" value="<%=userIntegral%>" />
<c:set var="userVip" value="<%=userVip%>" />--%>
<html>
<head>
    <title>订单操作</title>
    <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link rel="stylesheet" href="/static/toastr/toastr.min.css">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/bootstrap/js/bootstrap.min.js"></script>
    <script src="/static/js/home/mycomtyorder.js"></script>
    <script src="/static/toastr/toastr.min.js"></script>

    <style type="text/css">
        span{
            color:#008000;
            font-weight: 900;
        }
        /*只显示纵向滑动条*/
        html { overflow-x: hidden; overflow-y: auto; }
        /*右边内容左右边距*/
        .row{
            margin-left: 30px;
            margin-right: 10px;
        }
        .table-striped > tbody > tr:nth-of-type(odd){
            background-color: lavender;
        }
        .table>tbody>tr{
            height:50px;
        }
        img{
            width: 50px;
            height: 50px;
        }
    </style>

    <script>
        var ctx='${ctx}'
        var state='${userVip}';
    </script>
</head>
<body>
<div class="row">
    <div>
        <h4>我的积分：<span style="color: orangered">${userIntegral}</span> &nbsp;&nbsp;&nbsp;&nbsp;我的会员等级 :<span id="vip" style="color: red"></span></h4>
        <table  id="mytable" class="table table-striped table-hover table-condensed table-bordered">
            <thead>
            <tr>
                <th>兑换商品图片</th>
                <th>兑换商品地址</th>
                <th>花费积分</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <c:forEach items="${pageInfo.list}" var="myComorder" varStatus="status">
                <tr class="infoPic">
                    <td><img src="/img/picImg?url=${myComorder.commodity_pic}" /></td>
                    <td style="max-width: 300px;white-space: nowrap;text-overflow: ellipsis;overflow: hidden" onmousemove="removeClassType(this)">${myComorder.commodity_address}</td>
                    <td>${myComorder.usedIntegral}</td>
                    <td>
                        <div class="btn-group">
                            <button type="button" class="btn btn-danger" onclick="deleteOrder('${myComorder.id}')" style="margin-left: 10px" data-toggle="modal" data-target="#deleteModal">删除</button>
                            <c:choose>
                                <c:when test="${myComorder.state =='0'}">
                                    <button type="button" class="btn btn-danger" onclick="getOrder('${myComorder.id}')" style="margin-left: 10px" data-toggle="modal" data-target="#getModal">确认收货</button>
                                </c:when>
                                <c:otherwise>
                                    <button type="button" class="btn btn-primary" style="margin-left: 10px"  disabled>已收货</button>
                                </c:otherwise>
                            </c:choose>
                        </div>
                    </td>
                </tr>

            </c:forEach>
            </tbody>
        </table>
        <%--分页--%>
        <p>
            当前 <span>${pageInfo.pageNum}</span> 页,总 <span>${pageInfo.pages}</span> 页,共 <span>${pageInfo.total}</span> 条记录
        </p>
        <ul class="pagination">
            <li><a href="${ctx}homeHigh/myComtyoOrderList">第一页</a> </li>
            <c:choose>
                <c:when test="${pageInfo.hasPreviousPage == 'true'}">
                    <li><a href="${ctx}homeHigh/myComtyoOrderList?pageNum=${pageInfo.prePage}")>上一页</a></li>
                </c:when>
                <c:otherwise>
                    <li><a href="${ctx}homeHigh/myComtyoOrderList?pageNum=1">上一页</a></li>
                </c:otherwise>
            </c:choose>
            <c:choose>
                <c:when test="${pageInfo.hasNextPage == 'true'}">
                    <li><a href="${ctx}homeHigh/myComtyoOrderList?pageNum=${pageInfo.nextPage}">下一页</a></li>
                </c:when>
                <c:otherwise>
                    <li><a href="${ctx}homeHigh/myComtyoOrderList?pageNum=${pageInfo.pages}">下一页</a></li>
                </c:otherwise>
            </c:choose>
            <li><a href="${ctx}homeHigh/myComtyoOrderList?pageNum=${pageInfo.pages}">最后一页</a></li>
        </ul>
    </div>

    <%--删除模态框--%>
    <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="deleteModalLaber">删除框</h4>
                </div>
                <div class="modal-body" id="active">
                    <input type="hidden" name="deleteId" id="deleteId"/>
                    <span> 确定删除吗?</span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="deleteActive">删除</button>
                </div>
            </div>
        </div>
    </div>

    <%--收货模态框--%>
    <div class="modal fade" id="getModal" tabindex="-1" role="dialog" aria-labelledby="deleteModal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="getModalLaber">收货框</h4>
                </div>
                <div class="modal-body" id="getactive">
                    <input type="hidden" name="getId" id="getId"/>
                    <span> 确定收货吗?</span>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="getInActive">收货</button>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>
